#include <stdio.h>
#include "../manager/manager.h"


void *gOpenLibrary(const char *name)
{
    char filename[128];
#ifdef WIN32
    sprintf(filename, "%s.dll", name);
    return LoadLibraryA(filename);
#endif
#ifdef __linux__
    char buff[128];
    sprintf(filename, "%s/lib%s.so", getcwd(buff,128), name);
    return dlopen(filename, RTLD_NOW);
#endif
}

void gCloseLibrary(void *handle)
{
#ifdef WIN32
    FreeLibrary((HMODULE)handle);
#endif
#ifdef __linux__
    dlclose(handle);
#endif
}

int main()
{
    void *handle1 = gOpenLibrary("plugin1");
    void *handle2 = gOpenLibrary("plugin2");
    Manager::instance().execute();
    if (handle1) {
        gCloseLibrary(handle1);
    }
    if (handle2) {
        gCloseLibrary(handle2);
    }

    return 0;
}
